package com.cw.DesignModel23.Behavioral.StrategyPattern.Strategy2;

import java.util.Random;

/**
 * 该策略是：如果上一局赢了，这局的手势就和上一局的相同；如果上一局输了，就随机出
 */
public class WinningStrategy implements Strategy {
    private Random random;
    /**
     * 保存上一局是赢还是输了
     */
    private boolean won = false;
    /**
     * 保存上一局出的手势
     */
    private Hand prevHand;

    public WinningStrategy(int seed) {
        random = new Random(seed);
    }
    public Hand nextHand() {
        if (!won) {
            prevHand = Hand.getHand(random.nextInt(3));
        }
        return prevHand;
    }
    public void study(boolean win) {
        won = win;
    }
}

